//
//  MenuCell.m
//  share_business
//
//  Created by baidufz on 2017/9/6.
//  Copyright © 2017年 wyl. All rights reserved.
//

#import "MenuCell.h"

@interface MenuCell ()

@property (weak, nonatomic) IBOutlet UIImageView *menuIcon;
@property (weak, nonatomic) IBOutlet UILabel *menuLabel;
@property (nonatomic, copy) Callback menuCallback;

@end

@implementation MenuCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        NSArray *array =[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
        UIView *contentView = [array firstObject];
//        contentView.backgroundColor = [UIColor clearColor];
        [self addSubview:contentView];

    }
    return self;
}

- (void)setMenu:(UIImage *)image name:(NSString *)name {
    _menuIcon.image = image;
    _menuLabel.text = name;
}

- (void)setClickCallback:(Callback) callback {
    if (callback) {
        _menuCallback = callback;
        [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click)]];
    }
}
    
- (void)click {
    if (_menuCallback) {
        _menuCallback();
    }
}

@end
